package ratemymacclass

import grails.test.*

class CourseTests extends GrailsUnitTestCase {
    protected void setUp() {
        super.setUp()
    }

    protected void tearDown() {
        super.tearDown()
    }

    void testALot() {
        mockDomain(Course, []) // make FBUser feel like it has all its methods
        mockDomain(Professor, [])
        mockDomain(Rating, [])
        mockDomain(ProfRating, [])

        def c = new Course(title: "Show and Tell", department: "DARK", courseNum: 200)
        def p = new Professor(firstName: "Ruddi", lastName: "Tamakloe", department: "TSEW")
        def r = new Rating(title: "Test", workload: 5, easiness: 5, useful: 5, learning: 5,
                major: "Comp Sci", professor: p, course: c)

        c.addToRatings(r)

        assertEquals(Course.count(), 0)
        c.save(failOnError: true)
        p.save(failOnError: true)
        r.save(failOnError: true)

        assertEquals(Course.count(), 1)
        assertEquals(Rating.count(), 1)
        assertEquals(c.ratings.size(), 1)

    }
}
